/*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */
package pe.edu.unmsm.cinfo.siga.datos;

import java.io.Serializable;
import java.util.Date;
import java.util.List;
import javax.persistence.Basic;
import javax.persistence.CascadeType;
import javax.persistence.Column;
import javax.persistence.Entity;
import javax.persistence.FetchType;
import javax.persistence.Id;
import javax.persistence.JoinColumn;
import javax.persistence.ManyToOne;
import javax.persistence.NamedQueries;
import javax.persistence.NamedQuery;
import javax.persistence.OneToMany;
import javax.persistence.Table;
import javax.persistence.Temporal;
import javax.persistence.TemporalType;
import javax.xml.bind.annotation.XmlRootElement;
import javax.xml.bind.annotation.XmlTransient;

/**
 *
 * @author alumno
 */
@Entity
@Table(name = "PROVISION")
@XmlRootElement
@NamedQueries({
    @NamedQuery(name = "Provision.findAll", query = "SELECT p FROM Provision p"),
    @NamedQuery(name = "Provision.findByCcCod", query = "SELECT p FROM Provision p WHERE p.ccCod = :ccCod"),
    @NamedQuery(name = "Provision.findByInsAluCod", query = "SELECT p FROM Provision p WHERE p.insAluCod = :insAluCod"),
    @NamedQuery(name = "Provision.findByModgCod", query = "SELECT p FROM Provision p WHERE p.modgCod = :modgCod"),
    @NamedQuery(name = "Provision.findByCcFech", query = "SELECT p FROM Provision p WHERE p.ccFech = :ccFech"),
    @NamedQuery(name = "Provision.findByCcTipo", query = "SELECT p FROM Provision p WHERE p.ccTipo = :ccTipo"),
    @NamedQuery(name = "Provision.findByCcCarg", query = "SELECT p FROM Provision p WHERE p.ccCarg = :ccCarg"),
    @NamedQuery(name = "Provision.findByCcAbon", query = "SELECT p FROM Provision p WHERE p.ccAbon = :ccAbon"),
    @NamedQuery(name = "Provision.findByCcCuotas", query = "SELECT p FROM Provision p WHERE p.ccCuotas = :ccCuotas"),
    @NamedQuery(name = "Provision.findByCcPlazo", query = "SELECT p FROM Provision p WHERE p.ccPlazo = :ccPlazo"),
    @NamedQuery(name = "Provision.findByCcCuotaCanc", query = "SELECT p FROM Provision p WHERE p.ccCuotaCanc = :ccCuotaCanc"),
    @NamedQuery(name = "Provision.findByCertCod", query = "SELECT p FROM Provision p WHERE p.certCod = :certCod"),
    @NamedQuery(name = "Provision.findByDepCod", query = "SELECT p FROM Provision p WHERE p.depCod = :depCod"),
    @NamedQuery(name = "Provision.findByCcObs", query = "SELECT p FROM Provision p WHERE p.ccObs = :ccObs")})
public class Provision implements Serializable {
    private static final long serialVersionUID = 1L;
    @Id
    @Basic(optional = false)
    @Column(name = "CC_COD")
    private Integer ccCod;
    @Column(name = "INS_ALU_COD")
    private Integer insAluCod;
    @Column(name = "MODG_COD")
    private String modgCod;
    @Basic(optional = false)
    @Column(name = "CC_FECH")
    @Temporal(TemporalType.DATE)
    private Date ccFech;
    @Basic(optional = false)
    @Column(name = "CC_TIPO")
    private short ccTipo;
    // @Max(value=?)  @Min(value=?)//if you know range of your decimal fields consider using these annotations to enforce field validation
    @Column(name = "CC_CARG")
    private Double ccCarg;
    @Column(name = "CC_ABON")
    private Double ccAbon;
    @Column(name = "CC_CUOTAS")
    private Integer ccCuotas;
    @Column(name = "CC_PLAZO")
    private Integer ccPlazo;
    @Column(name = "CC_CUOTA_CANC")
    private Integer ccCuotaCanc;
    @Column(name = "CERT_COD")
    private Integer certCod;
    @Column(name = "DEP_COD")
    private Integer depCod;
    @Column(name = "CC_OBS")
    private Short ccObs;
    @JoinColumn(name = "PROG_COD", referencedColumnName = "PROG_COD")
    @ManyToOne(fetch = FetchType.LAZY)
    private ProgramaGrupo progCod;
    @JoinColumn(name = "MOT_COD", referencedColumnName = "MOT_COD")
    @ManyToOne(fetch = FetchType.LAZY)
    private CtaConcepto motCod;
    @JoinColumn(name = "ALU_COD", referencedColumnName = "ALU_COD")
    @ManyToOne(fetch = FetchType.LAZY)
    private Alumno aluCod;
    @OneToMany(cascade = CascadeType.ALL, mappedBy = "provision", fetch = FetchType.LAZY)
    private List<Cancelacion> cancelacionList;

    public Provision() {
    }

    public Provision(Integer ccCod) {
        this.ccCod = ccCod;
    }

    public Provision(Integer ccCod, Date ccFech, short ccTipo) {
        this.ccCod = ccCod;
        this.ccFech = ccFech;
        this.ccTipo = ccTipo;
    }

    public Integer getCcCod() {
        return ccCod;
    }

    public void setCcCod(Integer ccCod) {
        this.ccCod = ccCod;
    }

    public Integer getInsAluCod() {
        return insAluCod;
    }

    public void setInsAluCod(Integer insAluCod) {
        this.insAluCod = insAluCod;
    }

    public String getModgCod() {
        return modgCod;
    }

    public void setModgCod(String modgCod) {
        this.modgCod = modgCod;
    }

    public Date getCcFech() {
        return ccFech;
    }

    public void setCcFech(Date ccFech) {
        this.ccFech = ccFech;
    }

    public short getCcTipo() {
        return ccTipo;
    }

    public void setCcTipo(short ccTipo) {
        this.ccTipo = ccTipo;
    }

    public Double getCcCarg() {
        return ccCarg;
    }

    public void setCcCarg(Double ccCarg) {
        this.ccCarg = ccCarg;
    }

    public Double getCcAbon() {
        return ccAbon;
    }

    public void setCcAbon(Double ccAbon) {
        this.ccAbon = ccAbon;
    }

    public Integer getCcCuotas() {
        return ccCuotas;
    }

    public void setCcCuotas(Integer ccCuotas) {
        this.ccCuotas = ccCuotas;
    }

    public Integer getCcPlazo() {
        return ccPlazo;
    }

    public void setCcPlazo(Integer ccPlazo) {
        this.ccPlazo = ccPlazo;
    }

    public Integer getCcCuotaCanc() {
        return ccCuotaCanc;
    }

    public void setCcCuotaCanc(Integer ccCuotaCanc) {
        this.ccCuotaCanc = ccCuotaCanc;
    }

    public Integer getCertCod() {
        return certCod;
    }

    public void setCertCod(Integer certCod) {
        this.certCod = certCod;
    }

    public Integer getDepCod() {
        return depCod;
    }

    public void setDepCod(Integer depCod) {
        this.depCod = depCod;
    }

    public Short getCcObs() {
        return ccObs;
    }

    public void setCcObs(Short ccObs) {
        this.ccObs = ccObs;
    }

    public ProgramaGrupo getProgCod() {
        return progCod;
    }

    public void setProgCod(ProgramaGrupo progCod) {
        this.progCod = progCod;
    }

    public CtaConcepto getMotCod() {
        return motCod;
    }

    public void setMotCod(CtaConcepto motCod) {
        this.motCod = motCod;
    }

    public Alumno getAluCod() {
        return aluCod;
    }

    public void setAluCod(Alumno aluCod) {
        this.aluCod = aluCod;
    }

    @XmlTransient
    public List<Cancelacion> getCancelacionList() {
        return cancelacionList;
    }

    public void setCancelacionList(List<Cancelacion> cancelacionList) {
        this.cancelacionList = cancelacionList;
    }

    @Override
    public int hashCode() {
        int hash = 0;
        hash += (ccCod != null ? ccCod.hashCode() : 0);
        return hash;
    }

    @Override
    public boolean equals(Object object) {
        // TODO: Warning - this method won't work in the case the id fields are not set
        if (!(object instanceof Provision)) {
            return false;
        }
        Provision other = (Provision) object;
        if ((this.ccCod == null && other.ccCod != null) || (this.ccCod != null && !this.ccCod.equals(other.ccCod))) {
            return false;
        }
        return true;
    }

    @Override
    public String toString() {
        return "pe.edu.unmsm.cinfo.siga.datos.Provision[ ccCod=" + ccCod + " ]";
    }
    
}
